/**
 * 前台的论坛+贴子开始
 * @author jinlong-dt
 */
FrontBBS = {}
//前台贴子初始化
FrontBBS.initFrontTopic = function(){
	var plateId = $(":hidden[name=plateId]").val().replace(/,/g,"");
	$('#front_topic_list').datagrid({
		width:960,
		height:'auto',
		striped: true,
		url:context+'/front/front-topic!topicListData.action?plateId='+plateId,
		remoteSort: false,
		idField:'id',
		columns:[[
					{field:'title',title:'标题',width:253,align:'center'},
					{field:'authorName',title:'发贴人',width:150,align:'center'},
					{field:'hits',title:'浏览量',width:100,align:'center'},
					{field:'review',title:'回复量',width:100,align:'center'},
					{field:'addDate',title:'发贴时间',width:150,align:'center'},
					{field:'id',title:'操作',width:173,align:'center',formatter:function(value,rec){
						return "<a href='"+context+"/front/front-topic!showTopic.action?topicId="+value+"' >进入</a>";
					}}
				]],
		pagination:true,
		loadMsg:'正在加载数据,请等待...',
		rownumbers:true
	});
	var p = $('#front_topic_list').datagrid('getPager');
	if (p){
		$(p).pagination({
			showPageList:false,
			beforePageText:'第',
			afterPageText:"页，共<font color='blue'> {pages} </font>页",
			displayMsg:"当前显示 <font color='red'>{from}</font> 到 <font color='red'>{to}</font> 条记录，共<font color='red'> {total} </font>条记录",
		});
	}
}
/**
 * 前台的论坛+贴子结束
 * @author jinlong-dt
 */

FrontBBS.bbsUser = function(){
	var is = confirm("确认是否申请为版主，非法申请会导致用户锁定！");
	if(is){
		var plateId = $(":hidden[name=plateId]").val().replace(/,/g,"");
		$.ajax({
			type:'POST',
			url:context+'/front/front-topic!joinPlateUserRelation.action?plateId='+plateId,
			success:function(text){
				if(text=='success'){
					alert("申请成功");
				}else if(text=='noUser'){
					$.messager.defaults={ok:"现在登录",cancel:"取消"};
					$.messager.confirm('', '请登录后进行评论：', function(r){
						if (r){
							location.href = context+'/front/member!login.action';
						}
					});
				}else{
					alert(text);
				}
			}
		})
	}
}

FrontTopic= {}
FrontTopic.inputTopic = function(){
	var is = confirm("确认发布新贴！");
	if(is){
		var plateId = $(":hidden[name=plateId]").val().replace(/,/g,"");
		$.ajax({
			type:'POST',
			url:context+'/front/member!isLoginUser.action',
			success:function(text){
				if(text=='true'){
					location.href = context+'/front/front-topic!inputTopic.action?plateId='+plateId;
				}else if(text=='false'){
					$.messager.defaults={ok:"现在登录",cancel:"取消"};
					$.messager.confirm('', '请登录后发布新贴：', function(r){
						if (r){
							location.href = context+'/front/member!login.action';
						}
					});
				}else{
					alert('else');
				}
			}
		})
	}
}

